const extractMetadata = (md) => {
    const match = md.match(/---\n([\s\S]*?)\n---/);
    return match ? match[1] : null;
}

export const parseMarkdown = (mdString) => {
    const mtStr = extractMetadata(mdString);
    const metadata = mtStr ? Object.fromEntries(new URLSearchParams(mtStr.trim())) : {};
    const content = mdString.replace(/---\n([\s\S]*?)\n---/, '');
    return {metadata, content}
}